export const isEmtyObject = (val: object) => {
  const keys = Object.keys(val);
  return keys.length === 0
}
/**
 * 
 * @param object1 默认的
 * @param object2 需要合并的
 * @returns 
 */
export const mergeObject = (object1: object, object2: object) => {
  return Object.assign({}, object1, object1)
}

export const isNumber = (val: unknown) => typeof val === 'number'
export const isString = (val: unknown) => typeof val === 'string'
export const isObject = (val: unknown) => typeof val === 'object'
export const transformUperCaseRow = (val: string) => val.replace(/[A-Z]/g, (match) => "-" + match.toLowerCase())
export const isFunction = (val: unknown) => typeof val === 'function'

// 获取属性
export function getAttributes(elem: HTMLElement) {
  if (!elem) return {}
  const attrs = {}
  const attrSource = Object.values(elem.attributes)
  attrSource && attrSource.length > 0 &&
    attrSource.forEach(att => {
      const { name, value } = att
      const _name = transformUperCaseRow(name)
      attrs[_name] = value
    })
  return attrs
}